﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Medical.Entity;
using Medical.Business;
using System.Data;

public partial class control_FaqFrm : System.Web.UI.UserControl
{
    protected DataTable dtSort = null;
    protected String strSort = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            InitData();
        }
    }

    protected void InitData()
    {
        dtSort = new BisSortInfo().GetAllSortList(ArticelTypeEnum.FeedBack);
        DataRow[] drList = dtSort.Select("ParentID=0");
        strSort="[";
        string strPSort = string.Empty;
        foreach (DataRow dr in drList)
        {
            string strSubSort = string.Empty;
            DataRow[] drSubList = dtSort.Select("ParentID=" + dr["ID"].ToString());
            foreach (DataRow temDr in drSubList)
            {
                strSubSort += (strSubSort != string.Empty ? "," : "") + "{\"name\":\"" + temDr["Name"].ToString() + "\",\"sortid\":\"" + temDr["ID"].ToString() + "\"}";
            }
            strPSort += (strPSort != string.Empty ? "," : "") + "{\"name\":\"" + dr["Name"].ToString() + "\",\"sortid\":\"" + dr["ID"].ToString() + "\",subsort:[" + strSubSort + "]}";
        }
        strSort += strPSort + "]";
    }

    ///// <summary>
    ///// 分类下拉菜单事件
    ///// </summary>
    ///// <param name="sender"></param>
    ///// <param name="e"></param>
    //protected void ddlSort_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    ddlSubSort.Items.Clear();
    //    if (ddlSort.SelectedValue != string.Empty)
    //    {
    //        DataTable dtSubSort = new BisSortInfo().GetSortList(Convert.ToInt32(ddlSort.SelectedValue), ArticelTypeEnum.FeedBack);
    //        foreach (DataRow dr in dtSubSort.Rows)
    //        {
    //            ddlSubSort.Items.Add(new ListItem(dr["Name"].ToString(), dr["ID"].ToString()));
    //        }
    //    }
    //    this.Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "window.location.hash=\"askdiv\";", true);
    //}


    //protected void btnAsk_Click(object sender, EventArgs e)
    //{
    //    string strTitle = txtTitle.Text.Trim();
    //    if (strTitle == String.Empty)
    //    {
    //        Until.AlertBefaultJS("请输入问题标题！", "window.location.hash=\"askdiv\";");
    //        return;
    //    }

    //    string strInfo = txtInfo.Text.Trim();
    //    if (strInfo == String.Empty)
    //    {
    //        Until.AlertBefaultJS("请输入问题描述！", "window.location.hash=\"askdiv\";");
    //        return;
    //    }
    //    string strCode = txtCode.Text.Trim().ToUpper();
    //    if (strInfo == String.Empty)
    //    {
    //        Until.AlertBefaultJS("请输入验证码！", "window.location.hash=\"askdiv\";");
    //        return;
    //    }
    //    if (Session["WebCheckCode"] != null && strCode == Session["WebCheckCode"].ToString())
    //    {
    //        FeedBackInfo Info = new FeedBackInfo();
    //        Info.ParentID = 0;
    //        Info.Phone = txtPhone.Text.Trim();
    //        Info.ReType = 0;
    //        Info.Title = txtTitle.Text.Trim();
    //        Info.SortID = Convert.ToInt32(ddlSubSort.SelectedValue);
    //        Info.Email = txtEmail.Text.Trim();
    //        Info.Info = strInfo;
    //        bool bResult = new BisFeedBack().Insert(Info);
    //        if (bResult)
    //        {
    //            Until.Alert("问题提交成功，请等待专家的答复！");
    //            txtTitle.Text = "";
    //            txtCode.Text = "";
    //            txtEmail.Text = "";
    //            txtInfo.Text = "";
    //            txtPhone.Text = "";
    //        }
    //        else
    //        {
    //            Until.AlertBefaultJS("问题提交失败，请重试！", "window.location.hash=\"askdiv\";");
    //        }
    //    }
    //    else
    //    {
    //        Until.AlertBefaultJS("验证码不正确，请重新输入！", "window.location.hash=\"askdiv\";");
    //        return;
    //    }
    //}
}